import express from 'express';
import async from 'async';
import db from './../lib/dbHelper';

module.exports = {
    index: function () {
        return function (request, response, next) {

            //1.读取菜单的列表
            function getmeun(cb) {
                let sql = "SELECT * FROM sys_menu WHERE m_status=1 AND m_status_delete=1 ORDER BY m_orderby "
                db.query(sql, [], function (err, result, fileds) {
                    cb(err, result, fileds);
                })

            }
            //2.相关网站信息
            function getwebInfo(cb) {

                let sql = "SELECT *FROM sys_website "
                db.query(sql, [], function (err, result, fileds) {
                    cb(err, result, fileds);
                })

            }


            async.parallel([getmeun, getwebInfo], function (err, values) {


          
                if (!err) {
                    response.render("./admin/index.html", {
                    meun:values[0][0],
                    webinfo:values[1][0][0]
                    });
                } else {
                    response.end("出错了")
                }
            })
        }
    }
}